﻿// JScript File


function TextEntryInteraction(owner)   //ура товарищи!!!
{
    this.owner = owner;
    var xmldom = CreateXmlDOM();
    this.Interact = function(event)
    {            
        var aEvent = event ? event : window.event;        
        var txt = aEvent.srcElement ? aEvent.srcElement : aEvent.target;
        var userResponse = this.owner.xml.getElementsByTagName("userResponse")[0];
        var nodes = userResponse.getElementsByTagName("value");
        var vNode = null;
        for (var i = 0; i < nodes.length; i++)
            if (nodes[i].attributes.getNamedItem("fieldIdentifier").value == txt.id)
            {
                vNode = nodes[i];
                break;
            }
        if (vNode == null)
        {
            vNode = xmldom.createElement("value");
            atrId = xmldom.createAttribute("fieldIdentifier");
            atrId.value = txt.id;
            vNode.attributes.setNamedItem(atrId);
            var urNode = this.owner.xml.getElementsByTagName("userResponse")[0];
            urNode.appendChild(vNode); //а вы хоть представляете, как сложно писать без IntelliSense?
        }
        
        if (!isMozilla) 
            vNode.text = txt.value;    
        else
            vNode.textContent = txt.value;            
    }
}

function TextEntryRendering(owner)
{
    this.owner = owner;
    
    this.Render = function()
    {
        try
        {
            var html = "";
            html += TransformNode(this.owner.xml, "xslt/ItemHeader.xsl.aspx");
            html += TransformNode(this.owner.xml, "xslt/TextEntryInteraction.xsl");
            return html;
        }
        catch (e)
        {
            ShowMessage(QTICommon_QuestionRenderingError + (e.message == undefined ? e : e.message));
        }
    }
}
